package com.xn.example.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/***
 * 重试机制可以使用retry或者Hystrix
 */

@RestController
public class TestController {
    @Autowired
    RestTemplate restTemplate;

    @RequestMapping("test/{name}")
    public String test01(@PathVariable String name){
        return restTemplate.getForEntity("http://localhost:9000/test01?name="+name,String.class).getBody().toString();
    }

    @RequestMapping("test02/{name}")
    public String test02(@PathVariable String name){
        return restTemplate.getForEntity("http://spring-cloud-producer/test01?name="+name,String.class).getBody().toString();
    }
}
